Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 3 - Geometric Styles / Using Geometric Styles


Wrapping Text to a Contour

You can wrap text to a contour by using a typographic shape as the dash shape. Since dashes must always be primitive shapes, you must convert a text or layout shape to a glyph or path shape before using it as a dash shape.

The sample function in Listing 3-16 creates a text shape, sets its font and text size, converts it to a path shape, and uses it to dash a curve.

Listing 3-16 Wrapping text

void WrapText(void)
{
   gxShape  aCurveShape, aTextShape;

   static gxCurve curveGeometry = {ff(25), ff(125), 
                                   ff(100), 0, 
                                   ff(225), ff(125)};

   gxDashRecord theDashRecord;


   aCurveShape = GXNewCurve(&curveGeometry);
   GXSetShapeFill(aCurveShape, gxOpenFrameFill);
   
   aTextShape = GXNewText(13,
                          (unsigned char *) "QuickDraw(TM) GX",  
                          nil);
   SetShapeCommonFont(aTextShape, timesFont);
   GXSetShapeTextSize(aTextShape, ff(35));
   GXSetShapeType(aTextShape, gxPathType);

   theDashRecord.attributes = gxBreakDash;  
   theDashRecord.dash = aTextShape;
   theDashRecord.advance = ff(330); 
   theDashRecord.phase = 0; 
   theDashRecord.scale = ff(35); 

   GXSetShapeDash(aCurveShape, &theDashRecord);
   GXDisposeShape(aTextShape);
      
   GXSetShapePen(aCurveShape, ff(35));
   
   GXDrawShape(aCurveShape);
   
   GXDisposeShape(aCurveShape);
}
This example sets the dash scale to equal the text size so that the glyphs do not become distorted by dash scaling.

The result of this function is depicted in Figure 3-72. Notice that QuickDraw GX rotates and places each glyph separately on the contour because the break dash attribute is set.

Figure 3-72 Wrapped text

Inside Macintosh: QuickDraw GX Typography contains more information about using typographic shapes.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help